home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10491 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.7 KB  |  60 lines

  1. Newsgroups: comp.lang.c++
  2. Path: netcom.com!marnold
  3. From: marnold@netcom.com (Matt Arnold)
  4. Subject: Re: Borland C++: exceptions aren't caught in dynamically loaded DLL (netscape plug-in)
  5. Message-ID: <marnoldDnxsJL.G7A@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. References: <313F7ED2.5B17@cpsc.ucalgary.ca>
  8. Date: Fri, 8 Mar 1996 06:54:57 GMT
  9. Sender: marnold@netcom19.netcom.com
  10.  
  11. Rob Kremer <kremer@cpsc.ucalgary.ca> writes:
  12.  
  13. >I've written a Netscape plug-in version of program that works without
  14. >problem as a stand-alone.  Plug-ins are DLLs that are loaded by
  15. >Netscape when required.  (Netscape is written in MS Visual C++, my
  16. >app is written in Borland C++ v4.52.)  
  17.  
  18. >Whenever an exception is thrown in the plug-in, the plug-in itself
  19. >can't catch it.  It's as though the "try" and "catch" blocks weren't
  20. >there at all.
  21.  
  22. >Does anyone have an knowledge about this problem, or, better yet,
  23. >a solution?  (Other than rewriting to avoid exceptions!)
  24.  
  25. You need to enable "compatible exceptions" in the...
  26.  
  27.    Options|Project|C++ Options|Exception handling/RTTI
  28.  
  29. ...page.  I assume you are creating a 16-bit DLL, as this option only
  30. applies to 16-bit targets.
  31.  
  32. Although Borland's on-line help gives a rather vague description of what 
  33. this option actually does, it basically puts a copy of Borland's core 
  34. exception-handling implementation into your DLL.  If you do this, your 
  35. DLL's throws an catches should start working.
  36.  
  37. Where is the exception implementation otherwise?  Well, normally, Borland 
  38. DLLs assume they will be linked with Borland EXEs.  In the normal scheme, 
  39. many DLLs can share the core exception code in the EXE, reducing wasted 
  40. memory.  This also allows exceptions thrown in a Borland DLL to be caught 
  41. in the EXE.  Unfortunately, this "nifty" scheme also means that your DLLs 
  42. (at when it comes to C++ exceptions) aren't "compatible" with non-Borland 
  43. EXEs; not to mention that any exception-handling in the DLL doesn't work 
  44. (as you discovered). 
  45.  
  46. Turning on "compatible exceptions" bypasses this whole thing and just 
  47. produces a "self-contained" DLL.  Compatible exceptions also implies that
  48. your DLL should not let exceptions "escape" from any of it's entry-points.
  49.  
  50. Regards,
  51. -------------------------------------------------------------------------
  52. Matt Arnold                       |        | ||| | |||| |  | | || ||
  53. marnold@netcom.com                |        | ||| | |||| |  | | || ||
  54. Boston, MA                        |      0 | ||| | |||| |  | | || ||
  55. 617.389.7384 (h) 617.576.2760 (w) |        | ||| | |||| |  | | || ||
  56. C++, MIDI, Win32/95 developer     |        | ||| 4 3 1   0 8 3 || ||
  57. -------------------------------------------------------------------------
  58.  
  59.  
  60.